package com.eagle.commons.vo;
import java.io.IOException;
import java.io.Reader;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class IbatisUtil {
	 public static SqlMapClient getSqlMapClient(){
		  Reader reader = null ;    
		        try {    
		        	/*HttpServletRequest  request = ServletActionContext.getRequest(); 
		        	System.out.println(request.getSession().getServletContext());
		    		String webpath=request.getSession().getServletContext().getRealPath("\\");*/
		        	System.out.println(System.getProperty("user.dir"));
		            reader = Resources.getResourceAsReader("com/eagle/commons/vo/ibatisxml/sqlmap-config.xml");    
		            SqlMapClient sqlmap = SqlMapClientBuilder.buildSqlMapClient(reader);    
		            return sqlmap;
		          
		        } catch (IOException e) {    
		            // TODO Auto-generated catch block    
		            e.printStackTrace();    
		        }  
		        return null;
		 }
	

}
